package com.baizhi.action;

import com.alibaba.fastjson.JSON;
import com.baizhi.Subway;
import com.baizhi.service.SubwayService;
import com.github.pagehelper.PageInfo;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


public class Function {
    private SubwayService sc;
    private Subway c;
    private int pageSize;
    private int pageIndex=1;
    public void insertSubway(){
        sc.insert(c);
    }
    public void pageHelper(){
        HttpServletResponse response = ServletActionContext.getResponse();
        response.setCharacterEncoding("utf-8");
        try {
            PrintWriter writer = response.getWriter();
            PageInfo<Subway> page = sc.page(pageIndex, pageSize);
            String s = JSON.toJSONString(page);
            writer.print(s);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public Subway getC() {
        return c;
    }

    public void setC(Subway c) {
        this.c = c;
    }

    public SubwayService getSc() {
        return sc;
    }

    public void setSc(SubwayService sc) {
        this.sc = sc;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }
}
